//
//  ViewController.m
//  keyboard
//
//  Created by 遇水 on 16/3/12.
//  Copyright © 2016年 遇水. All rights reserved.
//

#import "ViewController.h"
#import "ChatBar.h"
#import "UIView+Extension.h"

@interface ViewController ()<ChatBarDelegate>

@property (nonatomic, strong) ChatBar    *chatBar;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //还没有设置尺寸无法显示出来, 可以设置一个类方法， 直接在控件内容部设置控件的frame
    ChatBar *chatBar = [[ChatBar alloc]init];
    chatBar.delegate = self;
//    chatBar.chatBarHeight = 45;
    chatBar.x = 0;
    chatBar.height = 45;
    chatBar.y = self.view.height -  chatBar.height;
    chatBar.width = self.view.width;
    
//    chatBar.superView = self.view;
    [self.view addSubview:chatBar];
    self.chatBar = chatBar;
    
}


-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.chatBar endEdit];
}

#pragma mark - delegate

-(void)chatBar:(ChatBar *)chatBar sendMessage:(NSString *)message
{
    NSLog(@"------message");
}

-(void)chatBar:(ChatBar *)chatBar sendLocation:(CLLocationCoordinate2D)location
{
    NSLog(@"---------发送地址消息");
}

-(void)chatBar:(ChatBar *)chatBar sendPictures:(NSArray<UIImage *> *)images
{
    NSLog(@"--------发送图片消息");
}


-(void)chatBar:(ChatBar *)chatBar sendVoice:(NSString *)vocieName time:(NSTimeInterval)time
{
    NSLog(@"--------发送语音消息");
}

-(void)chatBar:(ChatBar *)chatBar sendVodieMessage:(NSURL *)messageURL time:(NSTimeInterval)time
{
    NSLog(@"---------根据URL地址就获取数据");
    NSData *data = [NSData dataWithContentsOfURL:messageURL];
    NSLog(@"%@", data);
    
}
@end
